In [6]:
from __future__ import division
import numpy as np
import matplotlib.pyplot as plt
import matplotlib as mpl
mpl.rcParams['lines.linewidth'] = 2
mpl.rcParams['lines.color'] = 'r'
mpl.rcParams['axes.titlesize'] = 32
mpl.rcParams['axes.labelsize'] = 24
mpl.rcParams['axes.labelsize'] = 24
mpl.rcParams['xtick.labelsize'] = 24
mpl.rcParams['ytick.labelsize'] = 24
%matplotlib inline
def make_plot(x, y, xlabel="$x$", ylabel="$f_X(x)$"):
plt.figure(figsize=(12, 8))
plt.plot(x, y, 'k-', linewidth=3)
plt.xlabel(xlabel)
plt.ylabel(ylabel)
plt.xlim([min(x), max(x)])
In [7]:
import math
c = math.sqrt(2/3)
make_plot([0, c, c, 2*c, 2*c, 2*c + 1], [0, 0, c, 2*c, 0, 0])
In [8]:
x = np.arange(c, 2*c, c/100)
y = (x**2 - c**2)/2
x = [0] + list(x) + [2]
y = [0] + list(y) + [1]
make_plot(x, y, ylabel="$F_X(x)$")
In [9]:
#Exponential
x = np.arange(0, 10, 0.01)
y = np.exp(-1*x)
make_plot(x, y, ylabel="$f_T(t) / \lambda$", xlabel="$t$")
In [10]:
y = 1 - np.exp(-x)
make_plot(x, y, ylabel="$F_T(t)$", xlabel="$t$")
In [10]: